#include "board_object.h"
#include "game.h"
#include "texture_manager.h"
#include <SDL.h>

BoardObject::BoardObject() : GameObject(),
    m_bFlipped(false)
{
}

void BoardObject::load(std::unique_ptr<LoaderParams> const &pParams)
{
    // get position
    m_position = Vector2D(pParams->getX(),pParams->getY());
    
    // get drawing variables
    m_width = pParams->getWidth();
    m_height = pParams->getHeight();
    m_textureID = pParams->getTextureID();
    m_numFrames = pParams->getNumFrames();
    m_scale = pParams->getScale();
}

// draw the object to the screen
void BoardObject::draw()
{
    TextureManager::Instance()->drawFrame(m_textureID, static_cast<Uint32>(m_position.getX()), static_cast<Uint32>(m_position.getY()),
        m_width, m_height, m_currentRow, m_currentFrame, TheGame::Instance()->getRenderer(), m_angle, m_alpha, m_scale);
}

// apply velocity to current position
void BoardObject::update()
{
    //m_position += m_velocity;
    m_currentFrame = static_cast<int>((SDL_GetTicks() / (1000 / 3)) % m_numFrames);
}
